package math

import (
	"lesson01/instructions/base"
	"lesson01/rtda"
)

type DNeg struct {
	base.NoOperandsInstruction
}

func (e *DNeg) Execute(frame *rtda.Frame) {
	stack := frame.OperandStack()
	val := stack.PopDouble()
	stack.PushDouble(-val)
}

type FNeg struct {
	base.NoOperandsInstruction
}

func (e *FNeg) Execute(frame *rtda.Frame) {
	stack := frame.OperandStack()
	val := stack.PopFloat()
	stack.PushFloat(-val)
}

type INeg struct {
	base.NoOperandsInstruction
}

func (e *INeg) Execute(frame *rtda.Frame) {
	stack := frame.OperandStack()
	val := stack.PopInt()
	stack.PushInt(-val)
}

type LNeg struct {
	base.NoOperandsInstruction
}

func (e *LNeg) Execute(frame *rtda.Frame) {
	stack := frame.OperandStack()
	val := stack.PopLong()
	stack.PushLong(-val)
}
